<!DOCTYPE html>
<html>
<?php $this->load->view('admin/public/header.html');?>

<body class="childrenBody">
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <div class="layui-inline">
            <a class="layui-btn" style="display: block;margin-fight: 30px; margin-bottom: 15px" href="<?php echo site_url('admin/finance/add')?>">添加账户</a>
        </div>
        <form class="layui-form" style="display: flex">
            <div class="layui-inline">
                <div class="layui-input-inline" style="display:flex; ">
                    <input type="text" class="layui-input searchVal1" placeholder="请输入公司名字" style="display: block; width: 140px;margin-right: 10px;"/>
                    <input type="text" class="layui-input searchVal2" placeholder="手机号"  style="display: block; width: 140px;margin-right: 10px;" />
                    <input type="text" class="layui-input searchVal3" placeholder="支付宝账户"  style="display: block; width: 140px;margin-right: 10px;" />
                    <div class="layui-form-item magt">
                        <label class="layui-form-label">账户状态</label>
                        <div class="layui-input-block" style="width: 140px">
                            <select name="status" class="searchVal5" lay-verify="require" lay-search >
                                <option value="">请选择账户状态</option>
                                <option value="1">正常</option>
                                <option value="2">审核中</option>
                                <option value="3">审核失败</option>
                            </select>
                        </div>
                    </div>
                    <a class="layui-btn search_btn" data-type="reload" style="display: block;margin-left: 30px; ">搜索</a>
                </div>
            </div>
        </form>
    </blockquote>

    <table id="newsList" lay-filter="newsList" style="width: 100%; height: 100%"></table>


    <!--操作-->
    <script type="text/html" id="newsListBar">
        <a class="layui-btn layui-btn-xs"  lay-event="check">通过</a>
        <a class="layui-btn layui-btn-xs"  lay-event="checkno">拒绝</a>
    </script>
</form>
<script type="text/javascript">

    layui.use(['form','layer','laydate','table','laytpl'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table,
            page;
        //列表
        var tableIns = table.render({
            elem: '#newsList',
            url : '<?php echo site_url("admin/finance/getList")?>',
            cellMinWidth : 95,
            page : true,
            height : "full-125",
            limit : 20,
            limits : [10,15,20,25],

            id : "newsListTable",
            cols : [[
                {field: 'id', title: 'ID', width:80, align:"center",sort:true},
                {field: 'name', title: '公司', width:100, align:"center",sort:true},
                {field: 'phone', title: '手机号',  width:110},
                {field: 'account', title: '支付宝账户', width:110},
                {field: 'user_name', title: '支付宝姓名', width:110},
                {field: 'status', title: '账户状态', width:80, align:"center"},
                {field: 'adminName', title: '操作人员', width:80, align:"center"},
                {field: 'create_time', title: '创建时间', width:150, align:"center"},
                {field: 'update_time', title: '更新时间', width:150},

                {title: '操作', field:'tools', templet:'#newsListBar',fixed:"right",align:"center"}
            ]],
            response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                ,statusCode: 200 //成功的状态码，默认：0
                ,msgName: 'msg' //状态信息的字段名称，默认：msg
                ,countName: 'count' //数据总数的字段名称，默认：count
                ,dataName: 'data' //数据列表的字段名称，默认：data
            } ,
            done:function(res,curr,count){
                page=curr;
            }
        });

        //搜索
        $(".search_btn").on("click",function(){
            table.reload("newsListTable",{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    // payTitle: $(".searchVal1").val(),  //订单标题
                    // trade_no: $(".searchVal2").val(),  //订单编号
                    // realName: $(".searchVal3").val(),  //用户姓名
                    // has_image: $(".searchVal4").val(),  //用户姓名
                }
            })
        });

        function addNews(edit){
            console.log(edit)
            var index = layui.layer.open({
                title : "用户信息",
                type : 2,
                content : "<?php echo site_url('admin/finance/check')?>",		//iframe层时,这个参数传URL
                success : function(layero, index){
                    var body = layui.layer.getChildFrame('body', index);
                    if(edit){
                        body.find("[name=id]").val(edit.id);
                        form.render();
                    }

                    setTimeout(function(){
                        layui.layer.tips('点击返回', '.layui-layer-setwin .layui-layer-close', {
                            tips: 3
                        });
                    },500)
                }
            })
            layui.layer.full(index);
            //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
            $(window).on("resize",function(){
                layui.layer.full(index);
            })
        }

        function delNews(edit){
            console.log(edit)
            var index = layui.layer.open({
                title : "用户信息",
                type : 2,
                content : "<?php echo site_url('seller/finance/del')?>",		//iframe层时,这个参数传URL
                success : function(layero, index){
                    var body = layui.layer.getChildFrame('body', index);
                    if(edit){
                        body.find("[name=id]").val(edit.id);
                        form.render();
                    }

                    setTimeout(function(){
                        layui.layer.tips('点击返回', '.layui-layer-setwin .layui-layer-close', {
                            tips: 3
                        });
                    },500)
                }
            })
            layui.layer.full(index);
            //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
            $(window).on("resize",function(){
                layui.layer.full(index);
            })
        }

        table.on('tool(newsList)', function(obj){
            console.log(obj)
            var layEvent = obj.event,
                data = obj.data;		//用户数据
            if(layEvent === 'check'){ //编辑
                layer.confirm('确定通过审核？',{icon:3, title:'提示信息'},function(index){
                    console.log(data.id);
                    $.ajax({
                        type:'post',
                        data:{id:data.id},
                        dataType: "json",
                        url:"<?php echo site_url('admin/finance/check')?>",
                        success:function(res){
                            if(res.code==200){
                                layer.close(index);
                            }else{
                                layer.msg(res.msg);
                            }
                        },
                        fail:function(){
                            layer.msg(res.msg);
                        }
                    })

                });
            }else if(layEvent === 'checkno'){ //删除
                layer.confirm('确定拒绝？',{icon:3, title:'提示信息'},function(index){
                    console.log(data.id);
                    $.ajax({
                        type:'post',
                        data:{id:data.id},
                        dataType: "json",
                        url:"<?php echo site_url('admin/finance/checkno')?>",
                        success:function(res){
                            if(res.code==200){
                                layer.close(index);
                            }else{
                                layer.msg(res.msg);
                            }
                        },
                        fail:function(){
                            layer.msg(res.msg);
                        }
                    })

                });
            }
        });

    })

</script>
</body>
</html>